package com.pharmacy.pharmacy.controller;

import com.pharmacy.pharmacy.domain.User;
import com.pharmacy.pharmacy.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【】Controller
 * 
 * @author 
 * @date 2025-05-08
 */
@CrossOrigin
@RestController
@RequestMapping("/system/user")
public class UserController 
{
    @Autowired
    private IUserService userService;

    /**
     * 查询【】列表
     */
    @GetMapping("/list")
    public List<User> list(User user)
    {

        System.out.println("查询user列表");
        List<User> users= userService.selectUserList(user);
        System.out.println(users);
        return users;
    }

    /**
     * 获取【】详细信息
     */
    @GetMapping(value = "/{id}")
    public User getInfo(@PathVariable("id") Long id)
    {
        return userService.selectUserById(id);
    }

    /**
     * 新增【】
     */
    @PostMapping
    public int add(@RequestBody User user)
    {
        return userService.insertUser(user);
    }

    /**
     * 修改【】
     */
    @PutMapping
    public int edit(@RequestBody User user)
    {

        System.out.println("-----------");
        return userService.updateUser(user);
    }

    /**
     * 删除【】
     */
    @DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return userService.deleteUserByIds(ids);
    }

}
